package com.dayuanit.dy17.atm.task;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

//@Component
//@EnableScheduling
//@EnableAsync
public class TestTask {

    public TestTask() {
        System.out.println("-----TestTask()--------");
    }

//    @Scheduled(cron = "0/1 * * * * ?")
//    @Async
    public void doTask() {
        System.out.println("------该吃饭了--------" +Thread.currentThread().getName());

        try {
            Thread.sleep(5*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

//    @Scheduled(cron = "0/1 * * * * ?")
//    @Async
    public void doTask2() {
        System.out.println("--------该工作了-----------" + Thread.currentThread().getName());
//        try {
//            Thread.sleep(5*1000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
    }
}
